<?php
$__tpl['header'] = '';
$__tpl['footer'] = '';

$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
if($id == 0 && empty($_GET['filename'])){
	go(PUB_DIR.'goods/');
}
$oGoods = new Goods();
if(!empty($_GET['filename'])){
	$goods = $oGoods->get_by_filename($_GET['filename'], '*', true);
}else{
	$goods = $oGoods->get_row($id, '*', true);
}
if(empty($goods)){
	go(PUB_DIR.'goods/');
}
if(empty($goods['filename'])){
	$goods['url'] = PUB_DIR.'goods/'.time_to_path($goods['addtime']).'/'.$goods['id'].'.html';
}else{
	$goods['url'] = PUB_DIR.'goods/v/'.$goods['filename'].'.html';
}
$vars['goods'] = $goods;

/*******************************************************************************
 * 读取相册
 *******************************************************************************/
$albums = $oGoods->get_album_all($goods['id'], '`path`,`alt`');
if(!empty($albums['list'])){
	// 相册
	foreach($albums['list'] as $key => $album){
		if(empty($album['alt']))$album['alt'] = $goods['name'];
		$albums['list'][$key] = $album;
	}
	$album_first = $albums['list'][0];
	$vars['album_first'] = $album_first;
	$vars['albums'] = $albums['list'];
}
?>